# @Time    : 2021/10/5 13:56
# @Author  : mirrorlied
# @Comment : 案例

from utils import PerformanceTesting, TrainAndPredict, dataWashing

# 读取数据
_, train_data = dataWashing()
# 再次清洗不必要的数据
X = train_data.drop(['is_default', 'loan_id', 'user_id'], axis=1, inplace=False)
labels = train_data['is_default']
X.fillna(0, inplace=True)
if __name__ == '__main__':
    # 测试一些奇奇怪怪的模型
    from lightgbm import LGBMClassifier
    from sklearn.neighbors import KNeighborsClassifier as KNN
    from sklearn.linear_model import LogisticRegression
    from sklearn.naive_bayes import GaussianNB
    from sklearn.svm import SVC

    # 构建模型
    # 模型需要用训练使用的fit()和预测使用的predict()
    # 预测正确率的验证集通过随机分割20%训练集获得(验证集不参与训练，且每次分割均不相同)

    model = LGBMClassifier(n_estimators=200)
    acc = PerformanceTesting(model, X, labels)
    print(f"LGBM 模型正确率:{acc*100}%")

    model = KNN()
    acc = PerformanceTesting(model, X, labels)
    print(f"KNN 模型正确率:{acc*100}%")

    model = GaussianNB()
    acc = PerformanceTesting(model, X, labels)
    print(f"GaussianNB 模型正确率:{acc*100}%")

    model = LogisticRegression()
    acc = PerformanceTesting(model, X, labels)
    print(f"LogisticRegression 模型正确率:{acc*100}%")

    model = SVC()
    acc = PerformanceTesting(model, X, labels)
    print(f"SVC 模型正确率:{acc*100}%")

    # 没有读取X_test的函数，不知道是谁的问题╬
    # pred = TrainAndPredict(model, X, labels, X_test)
    # print(pred)
